package com.twu.biblioteca.commands;

import com.twu.biblioteca.domain.Book;

import java.util.List;

public abstract class Command {
    protected AllActions allActions = new AllActions();
    private static final String LISTBOOKS = "List the books";
    private static final String RESERVEBOOK  = "Reserve";
    private static final String CHECKMEMBERSHIP = "Check membership" ;

    public abstract String execute(List<Book> books);

    public static Command createCommad(String command) {
        if(command.equalsIgnoreCase(LISTBOOKS)){
            return new ListBooksCommand();      }
        if(command.startsWith(RESERVEBOOK)){
            String bookId = command.substring(RESERVEBOOK.length()+1,command.length());
            return new ReserveBookCommand(bookId);  }
        if(command.equalsIgnoreCase(CHECKMEMBERSHIP)) {
            return new CheckMembershipCommand();
        }

        return null;
    }
}
